package com.neuedu.elmserver.controller;


import com.neuedu.elmserver.service.OrdersService;
import com.neuedu.elmserver.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author wyh
 * @since 2024-11-07
 */
@RestController
@RequestMapping("/orders")
@CrossOrigin
public class OrdersController {

    @Autowired
    private OrdersService ordersService;


    /**
     * 创建订单
     * @param
     * @return
     */
    @GetMapping("/createOrders")
    public ResultVO createOrders(Integer userId,Integer businessId,Integer addressId,Double total){
        return  ordersService.createOrders(addressId,userId,businessId,total);
    }
    /**
     * 根据订单编号查询订单信息
     * @param id
     * @return
     */
    @GetMapping("/getOrderById")
    public ResultVO getOrderById(Integer id){
        return  ordersService.getOrderById(id);
    }
    /**
     * 根据订单编号查询订单信息
     * @param order_Id
     * @return
     */
    @GetMapping("/getBusinessByOrderId")
    public ResultVO getBusinessByOrderId(Integer order_Id){ return ordersService.getBusinessByOrderId(order_Id);}
    @GetMapping("/changeStatus")
    public ResultVO changeStatus(Integer order_Id){return ordersService.changeStatus(order_Id);}
    @GetMapping("/listOrder")
    public ResultVO listOrder(Integer userId){return ordersService.listOrder(userId);}
    @GetMapping("/listOrderByID")
    public ResultVO listOrderByID( Integer userId){return ordersService.listOrderByID(userId);}
    @GetMapping("/getOrderItemsByUserId")
    public ResultVO getOrderItemsByUserId(Integer userId){return ordersService.getOrderItemsByUserId(userId);}
}
